﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace AnQinFrameWorkAPI.Entity.BaseInfo.Entity;

/// <summary>
///     部门模型
/// </summary>
[Table("Department")]
public class DepartmentModel
{
    #region 字段

    /// <summary>
    ///     部门表id
    /// </summary>
    [Key]
    [MaxLength(36)]
    public Guid Id { get; set; }

    /// <summary>
    ///     部门编码
    /// </summary>
    [MaxLength(50)]
    public string Code { get; set; }

    /// <summary>
    ///     部门名称
    /// </summary>
    [MaxLength(50)]
    public string Name { get; set; }

    /// <summary>
    ///     上级部门
    /// </summary>
    [MaxLength(36)]
    public Guid? SuperiorId { get; set; }

    /// <summary>
    ///     排序
    /// </summary>
    public int Order { get; set; }

    /// <summary>
    ///     创建时间
    /// </summary>
    public DateTime CreateTime { get; set; }

    #endregion
    
    #region 关联

    /// <summary>
    ///     部门
    /// </summary>
    public virtual DepartmentModel Department { get; set; }
    
    /// <summary>
    /// 下级部门列表
    /// </summary>
    public virtual ICollection<DepartmentModel> Children { get; set; } = new List<DepartmentModel>();
    
    #endregion
}